package com.see.front.view.staticdata;

import com.see.front.data.StaticDataAdaptor;
import com.vaadin.data.Property;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.ui.AbstractSelect.Filtering;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.VerticalLayout;

@SuppressWarnings("serial")
public class SectorComboBox extends VerticalLayout implements
		Property.ValueChangeListener {

	private static final String[] sectors = new String[] { "Basic Materials",
			"Healthcare", "Services" };

	public SectorComboBox() {
		setSpacing(true);

		ComboBox box = new ComboBox("");
		box.setInputPrompt("Please select Sector");

		for (int i = 0; i < sectors.length; i++) {
			box.addItem(sectors[i]);
		}

		box.setFilteringMode(Filtering.FILTERINGMODE_OFF);
		box.setImmediate(true);
		box.addListener(this);

		addComponent(box);
	}

	/*
	 * Shows a notification when a selection is made.
	 */
	public void valueChange(ValueChangeEvent event) {
		getWindow().showNotification("Selected sector: " + event.getProperty());
		if (event.getProperty() != null) {
		    TableLayout.loadFromDataSource(null, event.getProperty().toString(), null);
			
		}
	}
}